/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package algoGenetico;

import Rota.Mapa;

/**
 *
 * @author Fernando
 */
public class Individuo {

    private Cromossomo cromossomo;
    private double fitness = 0.0;

    public Individuo(Cromossomo cromossomo) {
        this.cromossomo = cromossomo;
    }

    public Cromossomo getCromossomo() {
        return cromossomo;
    }

    public double getFitness() {
        return fitness;
    }

    public void setCromossomo(Cromossomo cromossomo) {
        this.cromossomo = cromossomo;
    }

    public double calcularFitness(Mapa mapa) {
        fitness = 0.0;
        for (int cont = 0; cont < cromossomo.getGenes().size() - 1; cont++) {
            fitness += mapa.getDistsEntrePontos()[cromossomo.getGene(cont)][cromossomo.getGene(cont + 1)];
        }
      return fitness;
    }
}
